# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="3"

inherit git-2 eutils

DESCRIPTION="Runtime library for the D programming language"

HOMEPAGE="http://www.digitalmars.com/d/"


LICENSE="DMD"
SLOT="2"
KEYWORDS="~x86 ~amd64"
IUSE=""
EAPI="3"

RESTRICT="mirror"

PDEPEND="dev-lang/dmd
	dev-libs/druntime"

src_unpack() {

	EGIT_SOURCEDIR="${WORKDIR}/${PN}"
	EGIT_REPO_URI="git://github.com/D-Programming-Language/phobos.git"
	git-2_src_unpack

	EGIT_SOURCEDIR="${WORKDIR}/druntime"
	EGIT_REPO_URI="git://github.com/D-Programming-Language/druntime.git"
	git-2_src_unpack

	S="${WORKDIR}"
}

src_compile() {
	cd "${S}/${PN}"
	DMD="/usr/bin/dmd" make -f posix.mak || die "make failed"
# clean up
	find . -name "*.asm" -print0 | xargs -0 rm -v
	find . -name "*.mak" -print0 | xargs -0 rm -v
	find . -name "*.txt" -print0 | xargs -0 rm -v
	find . -name "*.ddoc" -print0 | xargs -0 rm -v
	find . -name "*.c" -print0 | xargs -0 rm -v
}

src_install() {
# lib
	dolib.a "${S}/phobos/generated/linux/release/32/libphobos2.a" || die "Install failed"

# includes
	rm -rf "${S}/phobos/generated"
	rm -rf "${S}/phobos/dmd"
	dodir /usr/include/phobos2
	mv "${S}/phobos"/* "${D}/usr/include/phobos2/"
}
